package com.example.demo.Controller;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2023-08-14
 * Time:14:15
 */

import com.example.demo.Service.UserService;
import com.example.demo.entity.Userinfo;
import com.example.demo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2023-08-02
 * Time:17:22
 */

//@RestController
@Controller
public class UserController {


    @Autowired
    private UserService userService;

    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/loginjudge")
    public String login(String username,String password){
        Userinfo userinfo = userMapper.login(username,password);

        if (userinfo == null){
            System.out.println("错误");
            return "/fail.html";
        }

        System.out.println("成功");
        return "/success.html";
    }

    @RequestMapping("/add")
    public String add(String username,String password){
        if (username == null || password == null){
            return "请填写完整!!";
        }
        System.out.println("注册成功");
        userMapper.add(username,password);
        return "/login.html";
    }
}
